Socket
Socket
Sign inDemoInstall

@types/ioredis

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/ioredis

TypeScript definitions for ioredis


Version published
Weekly downloads
1.5M
increased by6.45%
Maintainers
1
Weekly downloads
 
Created

What is @types/ioredis?

The @types/ioredis package provides TypeScript type definitions for the ioredis package, which is a robust, performance-focused, and full-featured Redis client for Node.js. By using @types/ioredis, developers can take advantage of TypeScript's static type checking for ioredis, ensuring that they use the ioredis API correctly.

What are @types/ioredis's main functionalities?

Connecting to Redis

This code sample demonstrates how to create a new Redis client instance to connect to a Redis server using default settings.

import Redis from 'ioredis';
const redis = new Redis();

Executing Redis Commands

This code sample shows how to set a key-value pair in Redis and then retrieve the value of a key asynchronously.

redis.set('key', 'value');
redis.get('key').then(result => console.log(result));

Working with Hashes

This code sample illustrates how to work with Redis hashes by setting and getting field values within a hash.

redis.hset('hashKey', 'field', 'value');
redis.hget('hashKey', 'field').then(result => console.log(result));

Publish/Subscribe

This code sample demonstrates the publish/subscribe pattern where one Redis client publishes a message to a channel and another client subscribes to that channel to receive messages.

const publisher = new Redis();
const subscriber = new Redis();
subscriber.subscribe('channel', () => {
  console.log('Subscribed to channel');
});
subscriber.on('message', (channel, message) => {
  console.log(`Received message: ${message} from channel: ${channel}`);
});
publisher.publish('channel', 'Hello world!');

Transactions

This code sample shows how to use a pipeline to execute a transaction in Redis, which includes multiple commands that are executed atomically.

const pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('baz');
pipeline.exec().then(results => {
  console.log(results);
});

Other packages similar to @types/ioredis

FAQs

Package last updated on 19 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc